#ifndef _FLASH_CTL_H_
#define _FLASH_CTL_H_

#include "config_fw.h"
//#include "mmpf_sensor.h"
//#include "mmp_reg_vif.h"
//#include "mmpf_pll.h"
#include "lib_retina.h"
#include "isp_if.h"


/*************************************************************************************************/
/* Venus Flash Definitions                                                                       */
/*************************************************************************************************/
#define FLASH_TORCH_MODE_MAX_LEVEL		0xFF	// 100%
#define FLASH_TORCH_MODE_MIN_LEVEL		0x00	// 0%

#define FLASH_CAMERA_MODE_MAX_LEVEL		0xFF	// 100%
#define FLASH_CAMERA_MODE_MIN_LEVEL		0x00	// 0%

#define FLASH_DEFAULT_LOW_LUX_TH		50

//typedef enum {
//	ISP_FLASH_STATUS_OFF			= 0,
//	ISP_FLASH_STATUS_ON				= 1
//} ISP_FLASH_STATUS;

typedef enum {
	ISP_FLASH_MODE_OFF				= 0,
	ISP_FLASH_MODE_CAMERA_FORCE_ON	= 1,
	ISP_FLASH_MODE_CAMERA_AUTO_ON	= 2,
	ISP_FLASH_MODE_VIDEO_FORCE_ON	= 3,
	ISP_FLASH_MODE_VIDEO_AUTO_ON	= 4
} ISP_FLASH_MODE;

typedef enum {
	ISP_FLASH_CTL_DIS				= 0,
	ISP_FLASH_CTL_EN				= 1
} ISP_FLASH_CTL;

typedef enum {
	ISP_FLASH_TYPE_CAMERA			= 0,
	ISP_FLASH_TYPE_VIDEO			= 1
} ISP_FLASH_TYPE;

/*************************************************************************************************/
/* Venus Flash Register                                                                          */
/*************************************************************************************************/
typedef struct {
	MMP_UBYTE			SelfControl;	// flash self control (control flash light by ISP or not)
	ISP_FLASH_STATUS	Status;			// flash real status (fired or not)
	ISP_FLASH_MODE		Mode;			// flash light mode (auto, force, off)
	MMP_UBYTE			TorchLevel;		// flash light level for torch mode
	MMP_UBYTE			CameraLevel;	// flash light level for camera mode
	MMP_ULONG			LowLuxTh;		// low lux threshold for auto flash mode
} VENUS_FLASH_CONFIG;

extern VENUS_FLASH_CONFIG gFlashConfig;

MMP_ERR  MMPF_FLASH_WriteI2C(MMP_USHORT usAddr, MMP_USHORT usData);
MMP_ERR  MMPF_FLASH_ReadI2C(MMP_USHORT usAddr, MMP_USHORT *usData);

/*************************************************************************************************/
/* Venus Flash API                                                                               */
/*************************************************************************************************/
void VR_Flash_Ctl(ISP_FLASH_CTL ctl, ISP_FLASH_TYPE type);
void VR_Flash_SetTorchLevel(MMP_UBYTE level);
void VR_Flash_SetCameraLevel(MMP_UBYTE level);
void VR_Flash_SetMode(ISP_FLASH_MODE mode);


/*************************************************************************************************/
/* Venus Flash Driver                                                                            */
/*************************************************************************************************/
void VR_Flash_Init(void);

void VR_Flash_SetFlashModeOn(void);
void VR_Flash_SetFlashModeOff(void);

void VR_Flash_SetTorchModeOn(void);
void VR_Flash_SetTorchModeOff(void);

//ISP_CMD_STATUS VR_Flash_SendCommand(MMP_ULONG cmd, void *buf_ptr, MMP_ULONG size, MMP_ULONG count);


#endif // _FLASH_CTL_H_
